package com.lifeng.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * Created by lifeng
 * 2018/1/10 15:32
 */
public class CommandUserSafe extends HystrixCommand {
    public CommandUserSafe(){
        super(HystrixCommandGroupKey.Factory.asKey("userGroup"));
    }
    @Override
    protected Object run() throws Exception {
        //调用真实的服务
        String user = "你好";
        //int a = 1/0;
        return user;
    }

    /** 当前调用方法发生异常时,降级执行此访问*/
    @Override
    protected Object getFallback() {
        return "错误了";
    }
}
